package com.ajieee.merge.runner.finance.dto;

import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.format.NumberFormat;
import com.ajieee.merge.exception.EtlException;
import lombok.Data;

/**
 * @author ajieee
 * @date 2025-10-03
 */
@Data
public class EtfQuoteExcelModel {

	@ExcelProperty("证券代码")
	private String fundCode;

	@ExcelProperty("证券简称")
	private String fundName;

	@ExcelProperty("开盘")
	private Double open;

	@ExcelProperty("最高")
	private Double high;

	@ExcelProperty("最低")
	private Double low;

	@ExcelProperty("今收")
	private Double close;

	@ExcelProperty("前收")
	private Double preClose;

	@ExcelIgnore
	private Double change;

	@ExcelProperty("涨跌幅（%）")
	private Double changeRatio;

	@ExcelProperty(value = "成交量（万份）")
	@NumberFormat(",##0.0###")
	private Double volume;

	@ExcelProperty("成交金额(万元)")
	@NumberFormat(",##0.0###")
	private Double amount;

	public Double getChange() {
		return close - preClose;
	}

	public Double getVolume() {
		return volume != null ? volume * 10000 : null;
	}

	public Double getAmount() {
		return amount != null ? amount * 10000 : null;
	}

	public void validate() {
		if (fundCode == null || fundName == null || open == null || high == null || low == null || close == null
				|| preClose == null || changeRatio == null || volume == null || amount == null) {
			throw new EtlException("深交所行情数据异常");
		}
	}

}
